/* 
 * */
#include<stdio.h>
#include<string.h>
#define NUMBERSTUDENTS	20

struct students {
	char name[20];
	char group[10];
	int age;
	int regnumber;
};
//void add_student(struct students* p_dai1[], int* n);
//void del_student(struct students* p_dai1[], int* n);
//void list_student(struct students* p_dai1[], int* n);

void add_student(struct students p_dai1[], int* n)
{
/*	int index;
	printf("Enter the index:");
	scanf("%d",&index);
*/
	printf("Enter the student name:");
	scanf("%s",(p_dai1[*n].name));
	printf("Enter the age:");
	scanf("%d",&(p_dai1[*n].age));
	printf("Enter the regnumber:");
	scanf("%d",&(p_dai1[*n].regnumber));
	printf("Enter the group:");
	scanf("%s",p_dai1[*n].group);
	printf("Student %d added\n",*n);
	printf("Total students %d\n",*n);
	(*n)++;
}
void del_student(struct students p_dai1[], int* n)
{
	int index, i;
	printf("Enter the index to be deleted");
	scanf("%d",&index);
	for (i = index; i <= *n; i++){
		strcpy(p_dai1[i].name, p_dai1[i + 1].name);
		strcpy(p_dai1[i].group, p_dai1[i + 1].group);
		p_dai1[i].regnumber = p_dai1[i + 1].regnumber;
		p_dai1[i].age = p_dai1[i + 1].age;
	}
	printf("Student %d deleted", index);
	(*n)--;
}
void list_student(struct students p_dai1[], int* n)
{
	int i;
	for (i = 0;i < *n;i++){
		printf("%s,  ",p_dai1[i].name);
		printf("%s,  ",p_dai1[i].group);
		printf("%d,  ",p_dai1[i].age);
		printf("%d,  \n\n",p_dai1[i].regnumber);
	}
}

int main(void){
	int option;
	int students_now = 0;
	struct students dai1[NUMBERSTUDENTS];
//	struct students* p_dai1;
//	p_dai1[] = &dai1[];
	while (option != 0){
		printf("Enter (1) to add\nEnter (2) do delete\n"
				"Enter (3) to list\nEnter (0) to quit\n");
		scanf("%d",&option);
		switch(option){
			case 1:
				add_student(&dai1, &students_now);
				list_student(&dai1, &students_now);
				break;
			case 2:
				del_student(&dai1, &students_now);
			case 3:
				list_student(&dai1,&students_now);
			case 0:
				printf("Goodbye(from CASE 0)\n");
				break;
			default:
				printf("Goodbye(from default)...\n");
				break;
		}
	}
	return 0;
}
